﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using UofCASE.AgileProductLinerDSL.Nant.Tasks.Models;
using APLDTests.NantTests.Mocks;

namespace APLDTests.NantTests
{
    [TestClass]
    public class PlatformTest
    {
        Platform linux;
        Feature boots;
        Feature processFork;

        [TestInitialize]
        public void setup()
        {
            linux = new Platform("Linux");
            
            boots = new Feature("Boots");
            boots.AddToPlatform(linux, new DummyTest(true));
            boots.AddToPlatform(linux, new DummyTest(true));

            processFork = new Feature("Pocesses Fork");
            processFork.AddToPlatform(linux, new DummyTest(true));
        }

        [TestMethod]
        public void EnumeratesTests()
        {
            int count = 0;
            foreach (ITest test in linux)
            {
                count++;
            }
            Assert.AreEqual(3, count);
        }

        [TestMethod]
        public void ReportsSuccess()
        {
            Assert.IsTrue(linux.Passed);
            processFork.AddToPlatform(linux, new DummyTest(false));
            Assert.IsFalse(linux.Passed);
        }

        [TestMethod]
        public void FindsTestByFeatureAndTestKey()
        {
            ITest test = new DummyTest(false);
            processFork.AddToPlatform(linux, test);
            Assert.AreSame(test, linux.Find(test.Key));
        }
    }
}
